<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
load()->func('tpl');

$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$where=' WHERE  uniacid=:uniacid  ';
$data[':uniacid']=$_W['uniacid'];
if(isset($_GPC['keywords'])){
    $where.="  and (name LIKE  concat('%', :name,'%') or phone LIKE  concat('%', :name,'%'))";
    $data[':name']=$_GPC['keywords']; 
}
$sql="SELECT * FROM ".tablename('zh_yjm_cusmember') .$where." ORDER BY time desc";
$total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zh_yjm_cusmember').$where." ORDER BY time desc",$data);

$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$members=pdo_fetchall($select_sql,$data);
$pager = pagination($total, $pageindex, $pagesize);





if($op=='delete'){
    $res=pdo_delete('zh_yjm_cusmember',array('id'=>$_GPC['id']));
    // var_dump($res);die;
    if($res){
      message('删除成功',$this->createWebUrl('member',array()),'success');
    }else{
      message('删除失败','','error');
    }
}

include $this->template('web/member');